# This command list all files in the directory in.dir which contain the text string 'grid.gz'
# The recursive call makes it look through all sub-directories within in.dir\
# The full.names call makes it display the entire path and file name

tfiles = list.files(in.dir,pattern='.grid.gz',recursive=TRUE,full.names=TRUE)

# Below is an example of the first two elements from this call

[1] "/home1/99/jc152199/MicroclimateStatisticalDownscale/AWAPASCII/RawAWAP//Tmax/2006/tmax.2006010120060101.grid.gz"
[2] "/home1/99/jc152199/MicroclimateStatisticalDownscale/AWAPASCII/RawAWAP//Tmax/2006/tmax.2006010220060102.grid.gz"

# The basename() function, provides you with just the name of the file, without the directory

tt = basename(tfiles[1613])

# Below is an example of the output from this command

"tmin.2008060120080601.grid.gz"

# The dirname() function provides you with just the directory (recursive) for the file

rr=dirname(tfiles[1613])

# Below is an example of the output of this command

"/home1/99/jc152199/MicroclimateStatisticalDownscale/AWAPASCII/RawAWAP//Tmin/2008"


